{% extends 'AdminBundle:base:index.html.twig' %}
    {% block title %}任务{% endblock %}
    {% block description %}新建 任务.{% endblock %}
    {% block plugin_styles %}
        <link rel="stylesheet" href="/admin/assets/css/chosen.min.css"/>
    {% endblock %}

    {% block head %}{{ parent() }}{% endblock %}

    {% block breadcrumbs %}
        {% embed "AdminBundle:base:breadcrumbs.html.twig" %}
            {% block breadcrumb %}
                <li><a href="{{ path('taskqueuewaiting_index') }}">任务</a></li>
                <li class="active">新建</li>
            {% endblock %}
        {% endembed %}
    {% endblock %}


    {% block content %}
        {{ form_start(form) }}


        <div class="form-group">
            {{ form_label(form.templateId) }}

            <div class="col-sm-2">
                {{ form_widget(form.templateId) }}
                <span class="help-inline col-xs-12 col-sm-7">
                    <a style="cursor:pointer;" class="ui-sghref" href="{{ path('tasktemplate_new') }}"><span
                                class="ui-icon ace-icon fa fa-plus center bigger-110 blue"></span></a>

                            <span class="middle">{{ form_errors(form.templateId) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.deviceGroupId) }}

            <div class="col-sm-2">
                {{ form_widget(form.deviceGroupId) }}
                <span class="help-inline col-xs-12 col-sm-7">
                    <a style="cursor:pointer;" class="ui-sghref" href="{{ path('basegroup_new') }}"><span
                                class="ui-icon ace-icon fa fa-plus center bigger-110 blue"></span></a>
                            <span class="middle">{{ form_errors(form.deviceGroupId) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.deviceId) }}

            <div class="col-sm-2">
                {{ form_widget(form.deviceId) }}
                <span class="help-inline col-xs-12 col-sm-7">
                    <a style="cursor:pointer;" class="ui-sghref" href="{{ path('basedevice_new') }}"><span
                                class="ui-icon ace-icon fa fa-plus center bigger-110 blue"></span></a>
                            <span class="middle">{{ form_errors(form.deviceId) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="form-group">
            {{ form_label(form.webchatUsername) }}

            <div class="col-sm-2">
                {{ form_widget(form.webchatUsername) }}
                <span class="help-inline col-xs-12 col-sm-7">
                    <a style="cursor:pointer;" class="ui-sghref" href="{{ path('basewebchatuser_new') }}"><span
                                class="ui-icon ace-icon fa fa-plus center bigger-110 blue"></span></a>
                            <span class="middle">{{ form_errors(form.webchatUsername) }}</span>
                        </span>
            </div>
        </div>
        <div class="space-6"></div>

        <div class="clearfix form-actions">
            <div class="col-md-offset-3 col-md-9">
                <button class="btn btn-info" type="submit">
                    <i class="ace-icon fa fa-check bigger-110"></i>
                    Submit
                </button>
                &nbsp; &nbsp; &nbsp;
                <button class="btn" type="reset">
                    <i class="ace-icon fa fa-undo bigger-110"></i>
                    Reset
                </button>
            </div>
        </div>

        {{ form_end(form) }}

    {% endblock %}
    {% block plugin_scripts %}
        <script src="/admin/assets/js/chosen.jquery.min.js"></script>
        <script src="/admin/assets/js/self.cascader.js"></script>
    {% endblock %}

    {% block javascripts %}
        <script type="text/javascript">
            jQuery(function ($) {
                if (!ace.vars['touch']) {
                    $('.chosen-select').chosen({allow_single_deselect: true});

                    //resize the chosen on window resize
                    $(window)
                            .off('resize.chosen')
                            .on('resize.chosen', function () {
                                $('.chosen-select').each(function () {
                                    var $this = $(this);
                                    $this.next().css({'width': $this.parent().width()});
                                })
                            }).trigger('resize.chosen');
                    //resize chosen on sidebar collapse/expand
//                    $(document).on('settings.ace.chosen', function (e, event_name, event_val) {
//                        if (event_name != 'sidebar_collapsed') return;
//                        $('.chosen-select').each(function () {
//                            var $this = $(this);
//                            $this.next().css({'width': $this.parent().width()});
//                        })
//                    });
                }

                var cascaderCls = new cascader({
                    'parent': $('#adminbundle_taskqueuewaiting_deviceGroupId'),
                    'me': $('#adminbundle_taskqueuewaiting_deviceId'),
                    'uri': "{{ path('basedevice_by_group', {'id': "-slug-",'has_default':"default" }) }}",
                    'all': false
                });
                cascaderCls.asyncLoad();
                var cascaderCls = new cascader({
                    'parent': $('#adminbundle_taskqueuewaiting_deviceId'),
                    'me': $('#adminbundle_taskqueuewaiting_webchatUsername'),
                    'uri': "{{ path('basewebchatuser_by_device', {'id': "-slug-",'has_default':"default" }) }}",
                    'all': false
                });
                cascaderCls.asyncLoad();
            });

        </script>
    {% endblock %}
